<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>tinyOS: tSem.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">tinyOS
   &#160;<span id="projectnumber">v1.00</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('t_sem_8h_source.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">tSem.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="t_sem_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#ifndef TSEM_H</span></div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="preprocessor">#define TSEM_H</span></div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;</div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="preprocessor">#include &quot;tConfig.h&quot;</span></div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;</div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="preprocessor">#if !defined(TINYOS_ENABLE_SEM) || TINYOS_ENABLE_SEM == 1</span></div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="t_event_8h.html">tEvent.h</a>&quot;</span></div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="comment">// 信号量类型</span></div><div class="line"><a name="l00024"></a><span class="lineno"><a class="line" href="struct__t_sem.html">   24</a></span>&#160;<span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__t_sem.html">_tSem</a> {</div><div class="line"><a name="l00025"></a><span class="lineno"><a class="line" href="struct__t_sem.html#a8b516ab130f86e4b15ca025c98c3dc53">   25</a></span>&#160;    <a class="code" href="struct__t_event.html">tEvent</a> <a class="code" href="struct__t_sem.html#a8b516ab130f86e4b15ca025c98c3dc53">event</a>;               </div><div class="line"><a name="l00026"></a><span class="lineno"><a class="line" href="struct__t_sem.html#a86988a65e0d3ece7990c032c159786d6">   26</a></span>&#160;    uint32_t <a class="code" href="struct__t_sem.html#a86988a65e0d3ece7990c032c159786d6">count</a>;             </div><div class="line"><a name="l00027"></a><span class="lineno"><a class="line" href="struct__t_sem.html#a1cc8a4ba5eee24b560f9869012941e91">   27</a></span>&#160;    uint32_t <a class="code" href="struct__t_sem.html#a1cc8a4ba5eee24b560f9869012941e91">maxCount</a>;          </div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;} <a class="code" href="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F.html#ga3d7db90a4217a81ff9da67050935f66d">tSem</a>;</div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;</div><div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;<span class="comment">// 信号量的信息类型</span></div><div class="line"><a name="l00031"></a><span class="lineno"><a class="line" href="struct__t_sem_info.html">   31</a></span>&#160;<span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__t_sem_info.html">_tSemInfo</a> {</div><div class="line"><a name="l00032"></a><span class="lineno"><a class="line" href="struct__t_sem_info.html#a86988a65e0d3ece7990c032c159786d6">   32</a></span>&#160;    uint32_t <a class="code" href="struct__t_sem_info.html#a86988a65e0d3ece7990c032c159786d6">count</a>;             </div><div class="line"><a name="l00033"></a><span class="lineno"><a class="line" href="struct__t_sem_info.html#a1cc8a4ba5eee24b560f9869012941e91">   33</a></span>&#160;    uint32_t <a class="code" href="struct__t_sem_info.html#a1cc8a4ba5eee24b560f9869012941e91">maxCount</a>;          </div><div class="line"><a name="l00034"></a><span class="lineno"><a class="line" href="struct__t_sem_info.html#a80462c64b9184115aa568f08227f7f4a">   34</a></span>&#160;    uint32_t <a class="code" href="struct__t_sem_info.html#a80462c64b9184115aa568f08227f7f4a">taskCount</a>;         </div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;} <a class="code" href="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F.html#ga9ec305c3826b08a2777ef8f212693fe1">tSemInfo</a>;</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="keywordtype">void</span> <a class="code" href="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F.html#ga1a48fab4ce73fc72b1a2ed6fa8771f8e">tSemInit</a> (<a class="code" href="struct__t_sem.html">tSem</a> *sem, uint32_t startCount, uint32_t <a class="code" href="struct__t_sem.html#a1cc8a4ba5eee24b560f9869012941e91">maxCount</a>);</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;uint32_t <a class="code" href="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F.html#ga9946734436c2a1ab849654a72e0de0ce">tSemWait</a> (<a class="code" href="struct__t_sem.html">tSem</a> *sem, uint32_t waitTicks);</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;uint32_t <a class="code" href="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F.html#gac0e48f858c5a926f878b2815702307a0">tSemNoWaitGet</a> (<a class="code" href="struct__t_sem.html">tSem</a> *sem);</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;<span class="keywordtype">void</span> <a class="code" href="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F.html#ga7222219d3c608a5f9b941e17b1872731">tSemNotify</a> (<a class="code" href="struct__t_sem.html">tSem</a> *sem);</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;<span class="keywordtype">void</span> <a class="code" href="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F.html#ga477f63052c68e3a6ff28b7302291b3cf">tSemGetInfo</a> (<a class="code" href="struct__t_sem.html">tSem</a> *sem, <a class="code" href="struct__t_sem_info.html">tSemInfo</a> *info);</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;uint32_t <a class="code" href="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F.html#gab00399e50380c504049be19c6e5f81ab">tSemDestroy</a> (<a class="code" href="struct__t_sem.html">tSem</a> *sem);</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;<span class="preprocessor">#endif // TINYOS_ENABLE_SEM</span></div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;</div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;<span class="preprocessor">#endif </span><span class="comment">/* TSEM_H */</span><span class="preprocessor"></span></div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;</div><div class="ttc" id="struct__t_sem_html"><div class="ttname"><a href="struct__t_sem.html">_tSem</a></div><div class="ttdef"><b>Definition:</b> <a href="t_sem_8h_source.html#l00024">tSem.h:24</a></div></div>
<div class="ttc" id="struct__t_sem_html_a1cc8a4ba5eee24b560f9869012941e91"><div class="ttname"><a href="struct__t_sem.html#a1cc8a4ba5eee24b560f9869012941e91">_tSem::maxCount</a></div><div class="ttdeci">uint32_t maxCount</div><div class="ttdef"><b>Definition:</b> <a href="t_sem_8h_source.html#l00027">tSem.h:27</a></div></div>
<div class="ttc" id="struct__t_sem_info_html_a80462c64b9184115aa568f08227f7f4a"><div class="ttname"><a href="struct__t_sem_info.html#a80462c64b9184115aa568f08227f7f4a">_tSemInfo::taskCount</a></div><div class="ttdeci">uint32_t taskCount</div><div class="ttdef"><b>Definition:</b> <a href="t_sem_8h_source.html#l00034">tSem.h:34</a></div></div>
<div class="ttc" id="struct__t_sem_info_html_a86988a65e0d3ece7990c032c159786d6"><div class="ttname"><a href="struct__t_sem_info.html#a86988a65e0d3ece7990c032c159786d6">_tSemInfo::count</a></div><div class="ttdeci">uint32_t count</div><div class="ttdef"><b>Definition:</b> <a href="t_sem_8h_source.html#l00032">tSem.h:32</a></div></div>
<div class="ttc" id="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F_html_ga3d7db90a4217a81ff9da67050935f66d"><div class="ttname"><a href="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F.html#ga3d7db90a4217a81ff9da67050935f66d">tSem</a></div><div class="ttdeci">struct _tSem tSem</div></div>
<div class="ttc" id="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F_html_ga1a48fab4ce73fc72b1a2ed6fa8771f8e"><div class="ttname"><a href="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F.html#ga1a48fab4ce73fc72b1a2ed6fa8771f8e">tSemInit</a></div><div class="ttdeci">void tSemInit(tSem *sem, uint32_t startCount, uint32_t maxCount)</div><div class="ttdef"><b>Definition:</b> <a href="t_sem_8c_source.html#l00024">tSem.c:24</a></div></div>
<div class="ttc" id="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F_html_ga477f63052c68e3a6ff28b7302291b3cf"><div class="ttname"><a href="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F.html#ga477f63052c68e3a6ff28b7302291b3cf">tSemGetInfo</a></div><div class="ttdeci">void tSemGetInfo(tSem *sem, tSemInfo *info)</div><div class="ttdef"><b>Definition:</b> <a href="t_sem_8c_source.html#l00118">tSem.c:118</a></div></div>
<div class="ttc" id="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F_html_gab00399e50380c504049be19c6e5f81ab"><div class="ttname"><a href="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F.html#gab00399e50380c504049be19c6e5f81ab">tSemDestroy</a></div><div class="ttdeci">uint32_t tSemDestroy(tSem *sem)</div><div class="ttdef"><b>Definition:</b> <a href="t_sem_8c_source.html#l00134">tSem.c:134</a></div></div>
<div class="ttc" id="t_event_8h_html"><div class="ttname"><a href="t_event_8h.html">tEvent.h</a></div></div>
<div class="ttc" id="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F_html_ga9946734436c2a1ab849654a72e0de0ce"><div class="ttname"><a href="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F.html#ga9946734436c2a1ab849654a72e0de0ce">tSemWait</a></div><div class="ttdeci">uint32_t tSemWait(tSem *sem, uint32_t waitTicks)</div><div class="ttdef"><b>Definition:</b> <a href="t_sem_8c_source.html#l00041">tSem.c:41</a></div></div>
<div class="ttc" id="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F_html_gac0e48f858c5a926f878b2815702307a0"><div class="ttname"><a href="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F.html#gac0e48f858c5a926f878b2815702307a0">tSemNoWaitGet</a></div><div class="ttdeci">uint32_t tSemNoWaitGet(tSem *sem)</div><div class="ttdef"><b>Definition:</b> <a href="t_sem_8c_source.html#l00068">tSem.c:68</a></div></div>
<div class="ttc" id="struct__t_event_html"><div class="ttname"><a href="struct__t_event.html">_tEvent</a></div><div class="ttdef"><b>Definition:</b> <a href="t_event_8h_source.html#l00032">tEvent.h:32</a></div></div>
<div class="ttc" id="struct__t_sem_html_a8b516ab130f86e4b15ca025c98c3dc53"><div class="ttname"><a href="struct__t_sem.html#a8b516ab130f86e4b15ca025c98c3dc53">_tSem::event</a></div><div class="ttdeci">tEvent event</div><div class="ttdef"><b>Definition:</b> <a href="t_sem_8h_source.html#l00025">tSem.h:25</a></div></div>
<div class="ttc" id="struct__t_sem_info_html"><div class="ttname"><a href="struct__t_sem_info.html">_tSemInfo</a></div><div class="ttdef"><b>Definition:</b> <a href="t_sem_8h_source.html#l00031">tSem.h:31</a></div></div>
<div class="ttc" id="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F_html_ga7222219d3c608a5f9b941e17b1872731"><div class="ttname"><a href="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F.html#ga7222219d3c608a5f9b941e17b1872731">tSemNotify</a></div><div class="ttdeci">void tSemNotify(tSem *sem)</div><div class="ttdef"><b>Definition:</b> <a href="t_sem_8c_source.html#l00088">tSem.c:88</a></div></div>
<div class="ttc" id="struct__t_sem_html_a86988a65e0d3ece7990c032c159786d6"><div class="ttname"><a href="struct__t_sem.html#a86988a65e0d3ece7990c032c159786d6">_tSem::count</a></div><div class="ttdeci">uint32_t count</div><div class="ttdef"><b>Definition:</b> <a href="t_sem_8h_source.html#l00026">tSem.h:26</a></div></div>
<div class="ttc" id="struct__t_sem_info_html_a1cc8a4ba5eee24b560f9869012941e91"><div class="ttname"><a href="struct__t_sem_info.html#a1cc8a4ba5eee24b560f9869012941e91">_tSemInfo::maxCount</a></div><div class="ttdeci">uint32_t maxCount</div><div class="ttdef"><b>Definition:</b> <a href="t_sem_8h_source.html#l00033">tSem.h:33</a></div></div>
<div class="ttc" id="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F_html_ga9ec305c3826b08a2777ef8f212693fe1"><div class="ttname"><a href="group___xE4_xBF_xA1_xE5_x8F_xB7_xE9_x87_x8F.html#ga9ec305c3826b08a2777ef8f212693fe1">tSemInfo</a></div><div class="ttdeci">struct _tSemInfo tSemInfo</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="t_sem_8h.html">tSem.h</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
